using System;
using System.Collections.Generic;
using System.Text;

namespace PlayTime
{
    public enum TrickStatus { CurrentTrickInComplete, CurrentTrickComplete, AllTrickCompleted };
    public class Session
    {
        protected Player[] m_cPlayer;
        protected Deck m_cCardPack = null;
        protected Hand m_cHand = null;
        protected Position m_cDealerPosition;
        string m_cGameName;
        public BridgeTableDisplay m_ctableDisplay;
        public string GameName
        {
            set { m_cGameName = value; }
            get { return m_cGameName; }
        }
        public Session()
        {
            m_ctableDisplay = (BridgeTableDisplay)PlayTime.Factory.getDisplayForm("ContractBridge");
            m_cCardPack = new Deck();
            m_cPlayer = new BridgePlayer[4];
            m_cPlayer[0] = new BridgePlayer(Position.North,"Ali@North");
            m_cPlayer[1] = new BridgePlayer(Position.East,"Arnab@East");
            m_cPlayer[2] = new BridgePlayer(Position.South,"Saon@South");
            m_cPlayer[3] = new BridgePlayer(Position.West,"Manas@West");
            m_cDealerPosition = ChooseDealerPosition();
            m_cHand = new Hand(this);
        }

        ~Session()
        {
            m_cPlayer = null;
            m_cHand = null;
        }
        public virtual PartnerShip getPartnerShip(Position Pos)
        {
            return null;
        }
        public virtual Position ChooseDealerPosition()
        {
            return Position.North;
        }

        internal void Deal()
        {
            m_cHand.DealCards();
            m_ctableDisplay.ShowCardAllPosition();
        }
        public Hand Hand
        {
            get { return m_cHand; }
        }
        public BridgePlayer Dealer
        {
            get { return getPlayer(m_cDealerPosition); }
        }
        public Deck Deck
        {
            get { return m_cCardPack; }
        }

        internal BridgePlayer getPlayer(Position pos)
        {
            return (BridgePlayer)m_cPlayer[(int)pos];
        }

        public virtual void Auction()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        internal void Play()
        {
            m_cHand.Play();
           // throw new Exception("The method or operation is not implemented.");
        }

        internal void Score()
        {
            throw new Exception("The method or operation is not implemented.");
        }
    }
}
